package com.zablert.mainactivity.chat

import zyc.zalbert.viewmodel.CoreViewModel
import kotlin.random.Random

class ChatViewModel : CoreViewModel() {
    private var messages: MutableList<ChatParam> = mutableListOf()
    private var messagesOld = mutableListOf<ChatParam>()
    fun getOld(): MutableList<ChatParam> {
        return messagesOld
    }

    fun getMessages(): MutableList<ChatParam> {
        return messages
    }

    fun sendMessage(message: String) {
        messagesOld.clear()
        messagesOld.addAll(messages)
        messages.add(ChatParam(ChatItemType.MSG_NORMAL_RIGHT, message, System.currentTimeMillis()))
        if (Random.nextBoolean()) {
            messages.add(
                ChatParam(
                    ChatItemType.MSG_NORMAL_LEFT,
                    "对对对，你说的对",
                    System.currentTimeMillis()
                )
            )
        }
    }
}
//        messages.
